/**
 * 
 */
package pe.gob.foncodes.sega.bs.resources;

import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * @author caguilar
 *
 */
public class Messages {
	
	private static final String msgerror = "pe.gob.foncodes.sega.bs.resources.ErrorMessage";
	private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(msgerror);
	
	private static final String msgerrorData = "pe.gob.foncodes.sega.bs.resources.Message";
	private static final ResourceBundle RESOURCE_BUNDLE_DATA = ResourceBundle.getBundle(msgerrorData);
		
	public static String getString(String key) {		
		try {			
			return RESOURCE_BUNDLE.getString(key);
		} catch (MissingResourceException e) {
			return '!' + key + '!';
		}
	}
	
	public static String getString(String key, Object[] arg){
		try{
			MessageFormat formatter = new MessageFormat("");
			formatter.applyPattern(RESOURCE_BUNDLE.getString(key));
			return formatter.format(arg);
		}catch(MissingResourceException e)
		{
			return '!' + key +'!';
		}
		
	}
	
	public static String getStringMsg(String key) {		
		try {			
			return RESOURCE_BUNDLE_DATA.getString(key);
		} catch (MissingResourceException e) {
			return '!' + key + '!';
		}
	}	

}
